# @Author   : 懒羊羊
# @File     : jiesuan.py
# @Time     : 2024/12/4 21:16
import time

from selenium.webdriver.chrome import webdriver
from selenium.webdriver.common.by import By

from loginpage import login
from search import search
from look import look
from gouwuche import gwc

wd = webdriver.WebDriver()
wd.implicitly_wait(10)

# 登录账号
login(wd, 'lbxx', '123456')

# a = wd.find_element(By.CSS_SELECTOR, "input[name='keywords']")
# a.clear()
# a.send_keys("小米")
# 搜索商品
search(wd)
time.sleep(2)

# 点击商品 查看详细信息
look(wd)
time.sleep(2)
# wd.find_element(By.CSS_SELECTOR, "input[name='imageField']").click()


# wd.find_element(By.CSS_SELECTOR, "img[alt='小米su7']").click()


# wd.find_element(By.LINK_TEXT, "加入购物车").click()
# 加入购物车
gwc(wd)
time.sleep(1)

# 点击结算按钮
wd.find_element(By.CSS_SELECTOR, "img[alt='checkout']").click()
time.sleep(1)
# print(wd.window_handles)
# 点击配送至这个地址
# wd.find_element(By.XPATH, '//*[@id="theForm"]/div/table/tbody/tr[6]/td/input[1]').click()
# time.sleep(1)
# print(wd.window_handles)

# 选择快递方式
wd.find_element(By.CSS_SELECTOR, "input[name='shipping'][value= '3']").click()

# 选择支付方式
wd.find_element(By.CSS_SELECTOR, "input[name='payment'][value= '3']").click()
time.sleep(1)

# 点击提交订单按钮
wd.find_element(By.CSS_SELECTOR, "input[type='image']").click()
time.sleep(3)
